﻿using System;

namespace SharpGL.SceneGraph
{
    /// <summary>
    /// The ContextChangeAction enumeration is used
    /// to identify what kind of change is occuring
    /// in effect of a scene element.
    /// </summary>
    public enum ContextChangeAction
    {
        /// <summary>
        /// Effect created in OpenGL context.
        /// </summary>
        CreateInContext,

        /// <summary>
        /// Effect destroyed in OpenGL context.
        /// </summary>
        DestroyInContext
    }
    
    /// <summary>
    /// The ContextChangeEventArgs class.
    /// </summary>
    public class ContextChangeEventArgs : EventArgs
    {
        #region Private Fields

        private ContextChangeAction action = ContextChangeAction.CreateInContext;
        
        #endregion Private Fields

        #region Constructors

        public ContextChangeEventArgs(ContextChangeAction action)
        {
            if (action != ContextChangeAction.CreateInContext && action != ContextChangeAction.DestroyInContext)
                throw new ArgumentException("Must be CreateInContext or DestroyInContext.", "action");

            this.action = action;
        }

        #endregion Constructors

        #region Public Properties

        public ContextChangeAction Action
        {
            get { return action; }
            protected set { action = value; }
        }

        #endregion Public Properties
    }

    /// <summary>
    /// Represents the method that will handle the OpenGL
    /// context change event of a scene element.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">A ContextChangeEventArgs that contains the event data.</param>
    public delegate void ContextChangeEventHandler(object sender, ContextChangeEventArgs e);
}